﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        /// <summary>
        ///     Bulk insert.
        /// </summary>
        public void BulkInsert()
        {
            PreLogicSetting();

            if (!HasRow()) return;

            if (IsBulkStategy())
            {
                SetCommonSettingBulk();
                SetInternalDataSourceBulk();
                WriteToServer(false);
            }
            else
            {
                SetCommonSettingSingle();

                if (IsValidSingleInsert())
                {
                    SetInternalDataSourceSingle();
                    SetSqlInsertActionSingle();
                    ExecuteActionSingle();
                }
            }
        }
    }
}